import request from '@/utils/request';

/**
 * 获取用户收藏列表
*/
export function getFavoritesListApi() {
  return request({
    url: '/favorites',
    method: 'get',
  });
}

/**
 * 新建收藏夹
*/
export function createFavoriteApi(data) {
  return request({
    url: '/favorites',
    method: 'post',
    data
  });
}

/**
 * 删除收藏夹
*/
export function deleteFavoriteApi(favoriteId) {
  return request({
    url: `/favorites/${favoriteId}`,
    method: 'delete'
  });
}

/**
 * 更新收藏夹
*/
export function updateFavoriteApi(favoriteId, data) {
  return request({
    url: `/favorites/${favoriteId}`,
    method: 'patch',
    data
  });
}

/**
 * 收藏夹收藏视频
*/
export function favoriteVideoApi(favoriteId, videoId) {
  return request({
    url: `/favorites/${favoriteId}/videos/${videoId}`,
    method: 'post',
  });
}

/**
 * 收藏夹取消收藏视频
*/
export function unfavoriteVideoApi(favoriteId, videoId) {
  return request({
    url: `/favorites/${favoriteId}/videos/${videoId}`,
    method: 'delete',
  });
}

/**
 * 获取收藏夹收藏视频列表
*/
export function getFavoriteVideosApi(favoriteId, params) {
  return request({
    url: `/favorites/${favoriteId}/videos`,
    method: 'get',
    params
  });
}
